﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPay.Infrastructure.Unity.H5Pay
{
    public class GoodSHelper
    {
        /// <summary>
        /// 判断单品是否上传
        /// </summary>
        /// <param name="posgoods"></param>
        /// <param name="actgoods"></param>
        /// <param name="postGood"></param>
        /// <returns></returns>
        public bool Isup(string posgoods, string actgoods,ref List<PostGoods> postGood)
        {
            var istrue = false;
            //判断是否提交商品详情
            postGood = Newtonsoft.Json.JsonConvert.DeserializeObject<List<PostGoods>>(posgoods);
            String Gds = posgoods;

            if (!String.IsNullOrEmpty(actgoods) && postGood != null && postGood.Count > 0)
            {
                string[] gdsArr = actgoods.Split(',');
                if (gdsArr != null && gdsArr.Length > 0)
                {

                    List<string> gdist = new List<string>(gdsArr);
                    foreach (var item in gdist)
                    {
                        if (postGood.Exists(i => i.goods_id == item))
                        {
                            istrue = true;
                            break;
                        }
                    }
                }
            }
            return istrue;
        }
    }

    public class PostGoods
    {
        public String goods_id { get; set; }
        public String goods_name { get; set; }
        public decimal price { get; set; }
        public decimal quantity { get; set; }
    }
}
